package com.ship.dispatch.mapper.orderPay;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ship.dispatch.bean.orderPay.SpFundManage;
import com.ship.dispatch.bean.orderPay.SpFundManageDetail;
import com.ship.dispatch.bo.orderPay.SpFundManageDetailBo;
import com.ship.dispatch.bo.orderPay.SpFundManageDetailRq;
import com.ship.dispatch.bo.orderPay.SpFundManagePageBo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SpFundManageDetailMapper extends BaseMapper<SpFundManageDetail> {

    Page<SpFundManage> getManagePage(@Param(value = "dto") SpFundManagePageBo dto);

    List<SpFundManage> getList(@Param(value = "dto") SpFundManage dto);
    /**
     * 公司分组名称
     */
    @Select("select d.corporate_name from sp_fund_manage_detail d GROUP BY d.corporate_name")
    List<String> getCorporateNames();

    /**
     * 获取最新公司信息
     */
    @Select("select d.* from sp_fund_manage_detail d \n" +
            "where d.trade_body = #{tradeBody} and d.corporate_name = #{corporateName} \n" +
            "ORDER BY create_date DESC\n" +
            "LIMIT 1")
    SpFundManageDetail getCorporateTradeInfo(@Param("tradeBody") Integer tradeBody,@Param("corporateName") String corporateName);

    /**
     * 获取船舶代理相关公司信息集合
     */
    @Select("select d.* from sp_fund_manage_detail d where d.fund_manage_id in (select id from sp_fund_manage f where f.order_type in (1,2,3,4))")
    List<SpFundManageDetail> getShipAgencyAverageBalance();

    List<SpFundManageDetail> getManageDetailPage(@Param(value = "dto") SpFundManageDetailRq dto);

    List<SpFundManageDetail> getExportManageDetail(@Param(value = "dto") SpFundManageDetailBo dto);

}
